/*
 * CImageWatcher.h
 *
 *  Created on: 2018年5月11日
 *      Author: zhengboyuan
 */

#ifndef CIMAGEWATCHER_H_
#define CIMAGEWATCHER_H_

#include "ImageWatcher.h"
#include "DataStore.h"
#include "CHttpService.h"


class CImageWatcher: public ImageWatcher
{
public:
	CImageWatcher();
	virtual ~CImageWatcher();

	virtual void setDb(const char* filepath);

	virtual bool addImageDir(const char* imageDir, const char* urlPath);

	virtual int open(uint16_t port, const char* webroot);

	virtual void close();

	virtual bool isOpen();

	virtual bool addEvent(EventRecord& record);

	virtual bool addImage(ImageRecord& record);

	virtual int findImage(const char* company, const char* station, int num, time_t fromTime, time_t toTime, ImageRecord* records, int size);

	virtual int findEvent(const char* company, const char* station, int num, time_t fromTime, time_t toTime, EventRecord* records, int size);

	virtual bool queryImage(const char* filepath, ImageRecord& record);

	virtual bool queryEvent(const char* filepath, EventRecord& record);

	virtual bool deleteEvent(int id);

	virtual bool deleteImage(int id);

	virtual bool updateEvent(EventRecord& record);

protected:
	std::string getDefaultDbPath();

protected:
	std::shared_ptr< DataStore >	m_store;
	std::string	m_dbPath;
	CHttpService	m_httpService;

};

#endif /* CIMAGEWATCHER_H_ */
